<!DOCTYPE html>
<html lang="en">
  <head>
    <meta charset="UTF-8" />
    <meta http-equiv="X-UA-Compatible" content="IE=edge" />
    <meta name="viewport" content="width=device-width, initial-scale=1.0" />
    <title>Document</title>
  </head>
  <body>
    <script>
      /*输入：
      var c = {
       name:'xiaoming',
       age:'18'
     }
     iterate(c)
      */

      // 输出：["name: xiaoming", "age: 18"]
      var c = {
        name: "xiaoming",
        age: "18",
      };
      let arr = [];
      function iterate(obj) {
        for (let i in obj) {
          // console.log(i, obj[i]);
          arr.push(i + ":" + obj[i]);
        }
        console.log(arr);
      }
      iterate(c);
    </script>
  </body>
</html>
